package gdufs.stat.web;

import gdufs.stat.service.Utils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.PageContext;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.opensymphony.oscache.base.Cache;
import com.opensymphony.oscache.web.ServletCacheAdministrator;
import com.opensymphony.oscache.web.filter.ICacheKeyProvider;

public class IVUserCacheKeyProvider implements ICacheKeyProvider {
	
	Log logger = LogFactory.getLog(IVUserCacheKeyProvider.class);

	public String createCacheKey(HttpServletRequest request,
			ServletCacheAdministrator administrator, Cache cache) {
		String userId = Utils.getCurrentUserId(request);
		String key = administrator.generateEntryKey(userId, request, PageContext.APPLICATION_SCOPE);
		logger.debug("cache key:"+key);
		return key;
	}

}
